package com.peoit.honeycomb.domain.security;

import com.peoit.honeycomb.domain.BaseEntity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 后台权限管理员
 * Created by zhouqiu on 2015/10/15.
 */
@Entity
@Table(name="honeycomb_person")
public class Person extends BaseEntity {
    private  String name;

    private String password;
    //描述
    private String description;

    //角色关连==================================================
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "person_role",
            joinColumns = @JoinColumn(name = "person_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id"))
    private Set<Role> roles = new HashSet<Role>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Role> getRoles() {
        return roles;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }

    public static Person getPersonBy(String name){
        Person Person = new Person();
        Person.setId("1");
        Person.setName(name);
        Person.setPassword("123456");
        return Person;
    }
}
